package com.pet.system.email;

import java.io.File;

import com.pet.framework.util.Config;


public class EmailExecute extends SmtpMailSender implements EmailSender {
	private static final String STMP =Config.getValue("email.stmp");
	private static final String PWD  =Config.getValue("email.pwd");
	private static final String USER =Config.getValue("email.user");
	 

	public EmailExecute(String from){
        super(from);
	}
	public EmailExecute(String smtp,String from,String user,String password){
	    super(smtp, from, user, password);
	}
	
    public static EmailExecute createSmtpMailSender(String from) throws IllegalArgumentException{
        return new EmailExecute(from);
    }

    public static EmailExecute createESmtpMailSender(String from) throws IllegalArgumentException{    	
        return new EmailExecute(STMP, from, USER, PWD);
    }
    
    public static EmailExecute createESmtpMailSender(String from,String stmp,String user,String pwd) throws IllegalArgumentException{
        return new EmailExecute(stmp, from, user, pwd);
    }

    public boolean sendTextMail(String to,String subject,String content,File[] attachments) throws IllegalArgumentException{
        return sendMail(to,subject,content,attachments,false,false);
    }

    public boolean sendTextMail(String to,String subject,String content) throws IllegalArgumentException
    {
        return sendMail(to,subject,content,null,false,false);
    }

    public boolean[] sendTextMail(String[] to,String subject,String content) throws IllegalArgumentException
    {
        return sendMail(to,subject,content,null,false,false);
    }

    public boolean[] sendTextMail(String[] to,String subject,String content,File[] attachments) throws IllegalArgumentException
    {
        return sendMail(to,subject,content,attachments,false,false);
    }

    public boolean sendHtmlMail(String to,String subject,String content) throws IllegalArgumentException{
        return sendMail(to,subject,content,null,true,false);
    }

    public boolean[] sendHtmlMail(String[] to,String subject,String content) throws IllegalArgumentException{
        return sendMail(to,subject,content,null,true,false);
    }

    public boolean sendHtmlMail(String to,String subject,String content,File[] attachments) throws IllegalArgumentException
    {
        return sendMail(to,subject,content,attachments,true,false);
    }

    public boolean[] sendHtmlMail(String[] to,String subject,String content,File[] attachments) throws IllegalArgumentException
    {
        return sendMail(to,subject,content,attachments,true,false);
    }

}
